capture log close
log using CCES_analyses, replace text
//program:  CCES_analyses.do
//task:     Replication code for CCES analyses
//project:  Ideology, Information, and Social Welfare Preferences (American Politics Research)   
//authors: Hang Qi & Jake Haselswerdt
//updated 9/19/23

//program setup
version 18
clear all
set linesize 80
macro drop _all
set scheme s1mono
set more off

************************************************************************************
*** Part 1. Data Analysis
************************************************************************************
//chekcing variables and unconditional experimental results
use CCES.dta, clear
**global control variables
global control "pid7_clean age_ordinal White educ female faminc_clean"

**checking variables
*variables of interest
codebook eitc_support tanf_support eitc_ineq eitc_admin tanf_ineq tanf_admin ideology liberal conservative moderate polknow

*controls
codebook $control

**table 3. Unconditional experimental results
sum eitc_support tanf_support
ttest eitc_support, by(eitc_ineq)
ttest tanf_support, by(tanf_ineq)

//test H1 & H2
**eitc_ineq and ideology
ologit eitc_support i.eitc_ineq##c.ideology
eststo eitc_ideo 
ologit eitc_support i.eitc_ineq##c.ideology $control 
eststo eitc_ideo_cont

margins, predict(outcome(5)) over(eitc_ineq) at(ideology=(1(1)5))
marginsplot, title("EITC experiment") ytitle("Predicted probability of strong support") xtitle("") legend(ring(0) pos(7) col(1)) xlabel(, angle(45) labsize(small))ylabel(0(.1).4) recast(line) recastci(rarea) ci1opts(fcolor(%30)) ci2opts(fcolor(%30)) saving(Figures/eitc_ideo, replace)

**tanf_ineq and ideology
ologit tanf_support i.tanf_ineq##c.ideology 
eststo tanf_ideo
testparm i.tanf_ineq#c.ideology##c.ideology
di r(p)
ologit tanf_support i.tanf_ineq##c.ideology  $control 
eststo tanf_ideo_cont

margins, predict(outcome(5)) over(tanf_ineq) at(ideology=(1(1)5))
marginsplot, title("TANF experiment") ytitle("Predicted probability of strong support") xtitle("") legend(ring(0) pos(7) col(1)) xscale(r(0.75 5.25)) xlabel(, angle(45) labsize(small))ylabel(0(.1).4) recast(line) recastci(rarea) ci1opts(fcolor(%30)) ci2opts(fcolor(%30)) saving(Figures/tanf_ideo, replace)

**Figure 1. Combined ideology interaction graph
gr combine Figures/eitc_ideo.gph Figures/tanf_ideo.gph
gr export Figures/ideo_linear.png, as(png) replace

************************************************************************************
*** Part 2. Appendix
************************************************************************************
****************Appendix B. Descriptive Statistics of Survey Sample*****************
**table B.1.
codebook pid7_clean age_ordinal White educ female faminc_clean ideology
estpost summarize pid7_clean age_ordinal White educ female faminc_clean ideology

********************Appendix D. Ordered Logistic Regression Results*****************
global control "pid7_clean age_ordinal White educ female faminc_clean"

**table D.1. (eitc_ineq and ideology)
ologit eitc_support i.eitc_ineq##c.ideology 
eststo eitc_ideo
ologit eitc_support i.eitc_ineq##c.ideology $control
eststo eitc_ideo_cont

esttab eitc_ideo eitc_ideo_cont using Tables/eitc_ideo.txt, tab se(2) b(2) pr2 onecell label  nobaselevels nomtitles eqlabels(none) interaction(" X ") scalars(N) substitute(cut1 "Cutpoint 1" cut2 "Cutpoint 2" cut3 "Cutpoint 3" cut4 "Cutpoint 4") star(* 0.10 ** 0.05 *** 0.01) replace

**table D.2. (tanf_ineq and ideology)
ologit tanf_support i.tanf_ineq##c.ideology 
eststo tanf_ideo
ologit tanf_support i.tanf_ineq##c.ideology  $control
eststo tanf_ideo_cont

esttab tanf_ideo tanf_ideo_cont using Tables/tanf_ideo.txt, tab se(2) b(2) pr2 onecell label  nobaselevels nomtitles eqlabels(none) interaction(" X ")  scalars(N) substitute(cut1 "Cutpoint 1" cut2 "Cutpoint 2" cut3 "Cutpoint 3" cut4 "Cutpoint 4") star(* 0.10 ** 0.05 *** 0.01) replace

**table D.3. (eitc_ineq, ideology, and political knowledge)
ologit eitc_support i.eitc_ineq##c.ideology##c.polknow 
eststo eitc_ideo_polknow
ologit eitc_support i.eitc_ineq##c.ideology##c.polknow $control
eststo etic_ideo_polknow_cont

esttab eitc_ideo_polknow etic_ideo_polknow_cont using Tables/eitc_ideo_polknow.txt, tab se(2) b(2) pr2 onecell label  nobaselevels nomtitles eqlabels(none) interaction(" X ")  scalars(N) substitute(cut1 "Cutpoint 1" cut2 "Cutpoint 2" cut3 "Cutpoint 3" cut4 "Cutpoint 4") star(* 0.10 ** 0.05 *** 0.01) replace

**table D.4. (tanf_ineq, ideology, and political knowledge)
ologit tanf_support i.tanf_ineq##c.ideology##c.polknow 
eststo tanf_ideo_polknow
ologit tanf_support i.tanf_ineq##c.ideology##c.polknow $control
eststo tanf_ideo_polknow_cont

esttab tanf_ideo_polknow tanf_ideo_polknow_cont using Tables/tanf_ideo_polknow.txt, tab se(2) b(2) pr2 onecell label  nobaselevels nomtitles eqlabels(none) interaction(" X ")  scalars(N) substitute(cut1 "Cutpoint 1" cut2 "Cutpoint 2" cut3 "Cutpoint 3" cut4 "Cutpoint 4") star(* 0.10 ** 0.05 *** 0.01) replace

**figure D.1.
ologit eitc_support i.eitc_ineq##c.ideology##c.polknow $control
margins, predict(outcome(5)) dydx(eitc_ineq) at(ideology=(1(1)5) polknow=(0 8))
marginsplot, title("EITC") ytitle("Inadequacy treatment effect on" "probability of strong support") xtitle("") xscale(r(.75 5.25)) xlabel(, angle(45)) recast(line) recastci(rarea) ci1opts(fcolor(%30)) ci2opts(fcolor(%30)) legend(order(3 "Low knowledge" 4 "High knowledge")) yline(0, lpattern(dot) lcolor(gs8)) saving(Figures/eitc_ideopk, replace)

ologit tanf_support i.tanf_ineq##c.ideology##c.polknow $control
margins, predict(outcome(5)) dydx(tanf_ineq) at(ideology=(1(1)5) polknow=(0 8))
marginsplot, title("TANF") ytitle("Inadequacy treatment effect on" "probability of strong support") xtitle("") xscale(r(.75 5.25)) xlabel(, angle(45)) recast(line) recastci(rarea) ci1opts(fcolor(%30)) ci2opts(fcolor(%30)) legend(order(3 "Low knowledge" 4 "High knowledge")) yline(0, lpattern(dot) lcolor(gs8)) saving(Figures/tanf_ideopk, replace)

*combined graph - must install grc1leg (findit grc1leg)
grc1leg Figures/eitc_ideopk.gph Figures/tanf_ideopk.gph 
gr export Figures/ideopk.png, as(png) replace

**table D.5. (tanf, combined inadequacy treatment, and ideology)
use CCES_expanded.dta, clear
global control "pid7_clean age_ordinal White educ female faminc_clean"
ologit support i.experiment##i.combined_ineq##c.ideology, vce(cluster caseid) 
eststo H4p_ideo
ologit support i.experiment##i.combined_ineq##c.ideology $control, vce(cluster caseid)
eststo H4p_ideo_cont

esttab H4p_ideo H4p_ideo_cont using Tables/H4p_ideo.txt, tab se(2) b(2) pr2 onecell label  nobaselevels nomtitles eqlabels(none) interaction(" X ")  scalars(N) substitute(cut1 "Cutpoint 1" cut2 "Cutpoint 2" cut3 "Cutpoint 3" cut4 "Cutpoint 4") star(* 0.10 ** 0.05 *** 0.01) replace

**figure D.2.
ologit support i.experiment##i.combined_ineq##c.ideology $control, vce(cluster caseid)
margins, predict(outcome(5)) dydx(combined_ineq) over(experiment) at(ideology=(1(1)5))
marginsplot, title("") ytitle("Inadequacy treatment effect on" "probability of strong support") xtitle("") recast(line) recastci(rarea) ci1opts(fcolor(%30)) ci2opts(fcolor(%30)) xlabel(, angle(45)) legend(ring(0) pos(4) col(1)) yline(0, lpattern(dot) lcolor(gs8))
gr export Figures/h4p_ideo.png, as(png) replace

****Appendix E. Ordered Logistic Regression Results and Figures (Party ID as the Independent Variable of Interest)****
//test H1&H2
use CCES.dta, clear
global control "ideology age_ordinal White educ female faminc_clean"

**table E.1. (eitc_ineq and party ID)
ologit eitc_support i.eitc_ineq##c.pid7_clean 
eststo eitc_pid
ologit eitc_support i.eitc_ineq##c.pid7_clean $control
eststo eitc_pid_cont

esttab eitc_pid eitc_pid_cont using Tables/eitc_pid.txt, tab se(2) b(2) pr2 onecell label  nobaselevels nomtitles eqlabels(none) interaction(" X ") scalars(N) substitute(cut1 "Cutpoint 1" cut2 "Cutpoint 2" cut3 "Cutpoint 3" cut4 "Cutpoint 4") star(* 0.10 ** 0.05 *** 0.01) replace

margins, predict(outcome(5)) over(eitc_ineq) at(pid7_clean=(1(1)7))
marginsplot, title("EITC experiment") ytitle("Predicted probability of strong support") xtitle("") legend(ring(0) pos(7) col(1)) xlabel(, angle(45) labsize(small))ylabel(0(.1).4) recast(line) recastci(rarea) ci1opts(fcolor(%30)) ci2opts(fcolor(%30)) saving(Figures/eitc_pid, replace)

**table E.2. (tanf_ineq and party ID)
ologit tanf_support i.tanf_ineq##c.pid7_clean 
eststo tanf_pid
ologit tanf_support i.tanf_ineq##c.pid7_clean  $control
eststo tanf_pid_cont

esttab tanf_pid tanf_pid_cont using Tables/tanf_pid.txt, tab se(2) b(2) pr2 onecell label  nobaselevels nomtitles eqlabels(none) interaction(" X ")  scalars(N) substitute(cut1 "Cutpoint 1" cut2 "Cutpoint 2" cut3 "Cutpoint 3" cut4 "Cutpoint 4") star(* 0.10 ** 0.05 *** 0.01) replace

margins, predict(outcome(5)) over(tanf_ineq) at(pid7_clean=(1(1)7))
marginsplot, title("TANF experiment") ytitle("Predicted probability of strong support") xtitle("") legend(ring(0) pos(7) col(1)) xscale(r(0.75 5.25)) xlabel(, angle(45) labsize(small))ylabel(0(.1).4) recast(line) recastci(rarea) ci1opts(fcolor(%30)) ci2opts(fcolor(%30)) saving(Figures/tanf_pid, replace)

**figure E.1.
gr combine Figures/eitc_pid.gph Figures/tanf_pid.gph
gr export Figures/pid_linear.png, as(png) replace

**table E.3.(eitc_ineq, party ID, and political knowledge)
ologit eitc_support i.eitc_ineq##c.pid7_clean##c.polknow 
eststo eitc_pid_polknow
ologit eitc_support i.eitc_ineq##c.pid7_clean##c.polknow $control
eststo etic_pid_polknow_cont

esttab eitc_pid_polknow etic_pid_polknow_cont using Tables/eitc_pid_polknow.txt, tab se(2) b(2) pr2 onecell label  nobaselevels nomtitles eqlabels(none) interaction(" X ")  scalars(N) substitute(cut1 "Cutpoint 1" cut2 "Cutpoint 2" cut3 "Cutpoint 3" cut4 "Cutpoint 4") star(* 0.10 ** 0.05 *** 0.01) replace

margins, predict(outcome(5)) dydx(eitc_ineq) at(pid7_clean=(1(1)7) polknow=(0 8))
marginsplot, title("EITC") ytitle("Inadequacy treatment effect on" "probability of strong support") xtitle("") xscale(r(.75 5.25)) xlabel(, angle(45)) recast(line) recastci(rarea) ci1opts(fcolor(%30)) ci2opts(fcolor(%30)) legend(order(3 "Low knowledge" 4 "High knowledge")) yline(0, lpattern(dot) lcolor(gs8)) saving(Figures/eitc_pidpk, replace)

**table E.4.(tanf_ineq, party ID, and political knowledge)
ologit tanf_support i.tanf_ineq##c.pid7_clean##c.polknow 
eststo tanf_pid_polknow
ologit tanf_support i.tanf_ineq##c.pid7_clean##c.polknow $control
eststo tanf_pid_polknow_cont

esttab tanf_pid_polknow tanf_pid_polknow_cont using Tables/tanf_pid_polknow.txt, tab se(2) b(2) pr2 onecell label  nobaselevels nomtitles eqlabels(none) interaction(" X ")  scalars(N) substitute(cut1 "Cutpoint 1" cut2 "Cutpoint 2" cut3 "Cutpoint 3" cut4 "Cutpoint 4") star(* 0.10 ** 0.05 *** 0.01) replace

margins, predict(outcome(5)) dydx(tanf_ineq) at(pid7_clean=(1(1)7) polknow=(0 8))
marginsplot, title("TANF") ytitle("Inadequacy treatment effect on" "probability of strong support") xtitle("") xscale(r(.75 5.25)) xlabel(, angle(45)) recast(line) recastci(rarea) ci1opts(fcolor(%30)) ci2opts(fcolor(%30)) legend(order(3 "Low knowledge" 4 "High knowledge")) yline(0, lpattern(dot) lcolor(gs8)) saving(Figures/tanf_pidpk, replace)

****figure E.2. 
grc1leg Figures/eitc_pidpk.gph Figures/tanf_pidpk.gph
gr export Figures/pidpk.png, as(png) replace

**table E.5. (tanf, combined inadequacy treatment, and party ID)
use CCES_expanded.dta, clear
global control "ideology age_ordinal White educ female faminc_clean"
ologit support i.experiment##i.combined_ineq##c.pid7_clean, vce(cluster caseid) 
eststo H4p_pid
ologit support i.experiment##i.combined_ineq##c.pid7_clean $control, vce(cluster caseid)
eststo H4p_pid_cont

esttab H4p_pid H4p_pid_cont using Tables/H4p_pid.txt, tab se(2) b(2) pr2 onecell label  nobaselevels nomtitles eqlabels(none) interaction(" X ")  scalars(N) substitute(cut1 "Cutpoint 1" cut2 "Cutpoint 2" cut3 "Cutpoint 3" cut4 "Cutpoint 4") star(* 0.10 ** 0.05 *** 0.01) replace

**figure E.3.
margins, predict(outcome(5)) dydx(combined_ineq) over(experiment) at(pid7_clean=(1(1)7))
marginsplot, title("") ytitle("Inadequacy treatment effect on" "probability of strong support") xtitle("") recast(line) recastci(rarea) ci1opts(fcolor(%30)) ci2opts(fcolor(%30)) xlabel(, angle(45)) legend(ring(0) pos(4) col(1)) yline(0, lpattern(dot) lcolor(gs8))
gr export Figures/h4p_pid.png, as(png) replace

log close 
exit











